package com.thti.mecool.client.command.result.work;


import com.threeti.mecool.mobile.interfaces.dto.MemoDto;
import com.thti.mecool.client.base.BaseActivity;
import com.thti.mecool.client.base.Cache;
import com.thti.mecool.client.base.HandlerConstant;
import com.thti.mecool.client.command.ICommand;
import com.thti.mecool.client.model.biz.WorkmemoBizImpl;
import com.thti.mecool.client.protocol.work.GetWorkmemoResult;
import com.thti.mecool.client.service.Protocol;

public class GetWorkmemoCommand implements ICommand{

	@Override
	public void doCommand(Object o) {
		GetWorkmemoResult getWorkmemoResult=(GetWorkmemoResult)o;
		if(getWorkmemoResult!=null){
			if(getWorkmemoResult.getStatus()==1){
				WorkmemoBizImpl workmemoBizImpl=new WorkmemoBizImpl(Cache.getmContext());
				workmemoBizImpl.deleteTable("workmemo");
				for(MemoDto m:getWorkmemoResult.getMemos()){
					workmemoBizImpl.save(m);
				}
				BaseActivity.setDataFlag(HandlerConstant.WorkMemosCommand);
			}else{
				BaseActivity.setFailName("工作备忘");
				System.out.println(BaseActivity.getFailName());
				BaseActivity.setCurrentMesg(getWorkmemoResult.getMsg());
				BaseActivity.setDataFlag(HandlerConstant.CommandFail);
			}
		}
		
	}

	@Override
	public String getCommandID() {
		
		return Protocol.getWorkmemo;
	}

	@Override
	public Class<?> getCommandClass() {
		// TODO Auto-generated method stub
		return GetWorkmemoResult.class;
	}

}
